﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Dashboard
{
    public class DocumentNode : Canvas
    {
        public event OnDocNodeSelected DocNodeSelected;

        #region data
        public int DocID { get; set; }
        public string DocTitle { get; set; }
        #endregion

        #region ui 
        private Color borderColor = Color.FromArgb(255, 250, 0, 0);
        private Color centerColor = Color.FromArgb(255, 155, 0, 0);
        private Ellipse docBall;
        private TextBlock docLabel;
        private TextBlock toolTipControl;
        #endregion

        #region ctor
        public DocumentNode()
        {
            this.DocID = 0;
            this.DocTitle = string.Empty;

            RadialGradientBrush bgBrush = new RadialGradientBrush(centerColor, borderColor);
            this.docBall=new Ellipse();
            this.docBall.SetValue(WidthProperty, 10);
            this.docBall.SetValue(HeightProperty, 10);
            this.docBall.Fill = bgBrush;
            this.docBall.Stroke = new SolidColorBrush(borderColor);

            docLabel=new TextBlock();
            docLabel.Text = "Doc " + DocID;
            toolTipControl=new TextBlock();
            toolTipControl.Text = DocTitle;
            ToolTipService.SetToolTip(docBall, toolTipControl);

            this.docBall.MouseLeftButtonDown += new MouseButtonEventHandler(docBall_MouseLeftButtonDown);
        }

        void docBall_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.DocNodeSelected != null)
                this.DocNodeSelected(this.DocID);
        }
        #endregion

        #region binding
        public void BindData(int docID, string docTitle)
        {
            this.DocID = docID;
            this.DocTitle = docTitle;
        }
        #endregion
    }
}
